<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Whether opening broken archives is allowed</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="rararchive.open.html">« RarArchive::open</a></li>
      <li style="float: right;"><a href="rararchive.tostring.html">RarArchive::__toString »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.rararchive.html">RarArchive</a></li>
    <li>Whether opening broken archives is allowed</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="rararchive.setallowbroken" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">RarArchive::setAllowBroken</h1>
  <p class="verinfo">(PECL rar &gt;= 3.0.0)</p><p class="refpurpose"><span class="refname">RarArchive::setAllowBroken</span> &mdash; <span class="dc-title">Whether opening broken archives is allowed</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-rararchive.setallowbroken-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格 (method):</p>
   <div class="methodsynopsis dc-description">
    <span class="modifier">public</span> <span class="methodname"><strong>RarArchive::setAllowBroken</strong></span>(<span class="methodparam"><span class="type">bool</span> <code class="parameter">$allow_broken</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">过程化风格:</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>rar_allow_broken_set</strong></span>(<span class="methodparam"><span class="type"><a href="class.rararchive.html" class="type RarArchive">RarArchive</a></span> <code class="parameter">$rarfile</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$allow_broken</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   This method defines whether broken archives can be read or all the operations that
   attempt to extract the archive entries will fail. Broken archives are archives for
   which no error is detected when the file is opened but an error occurs when reading
   the entries.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-rararchive.setallowbroken-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">rarfile</code></dt>

     <dd>

      <p class="para">
       A <span class="type"><a href="class.rararchive.html" class="type RarArchive">RarArchive</a></span> object, opened with <span class="function"><a href="rararchive.open.html" class="function">rar_open()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">allow_broken</code></dt>

     <dd>

      <p class="para">
       Whether to allow reading broken files (<strong><code>true</code></strong>) or not (<strong><code>false</code></strong>).
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-rararchive.setallowbroken-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <strong><code>true</code></strong>  或者在失败时返回 <strong><code>false</code></strong>. It will only fail if the file has
   already been closed.
  </p>
 </div>

 
  <div class="refsect1 examples" id="refsect1-rararchive.setallowbroken-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-810">
    <p><strong>示例 #1 面向对象风格</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">retnull</span><span style="color: #007700">()&nbsp;{&nbsp;return&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">;&nbsp;}<br /></span><span style="color: #0000BB">$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"/multi_broken.part1.rar"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">/*&nbsp;Third&nbsp;argument&nbsp;omits&nbsp;"volume&nbsp;not&nbsp;found"&nbsp;message&nbsp;*/<br /></span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">RarArchive</span><span style="color: #007700">::</span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'retnull'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$a</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setAllowBroken</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$a</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getEntries</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$e</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

     <div class="example-contents"><p>以上例程的输出类似于：</p></div>
     <div class="example-contents screen">
<div class="cdata"><pre>
RarEntry for file &quot;file1.txt&quot; (52b28202)
int(1)
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-811">
    <p><strong>示例 #2 过程化风格</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">retnull</span><span style="color: #007700">()&nbsp;{&nbsp;return&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">;&nbsp;}<br /></span><span style="color: #0000BB">$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"/multi_broken.part1.rar"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">/*&nbsp;Third&nbsp;argument&nbsp;omits&nbsp;"volume&nbsp;not&nbsp;found"&nbsp;message&nbsp;*/<br /></span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rar_open</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'retnull'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">rar_allow_broken_set</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">rar_list</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">)&nbsp;as&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$e</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

   </div>
  </p>
 </div>


  <div class="refsect1 seealso" id="refsect1-rararchive.setallowbroken-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="rararchive.isbroken.html" class="methodname" rel="rdfs-seeAlso">RarArchive::isBroken()</a> - Test whether an archive is broken (incomplete)</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>